home *** CD-ROM | disk | FTP | other *** search
/ Hyper Stacks 1994 May / Hyper Stacks (Pacific HiTech)(1994)[Mac].iso / MacTools / Pennant Fever / background_2563.txt < prev    next >
Encoding:
Text File  |  1989-02-15  |  13.4 KB  |  508 lines

  1. -- background: 2563 from stack: in
  2. -- bmap block id: 4467
  3. -- flags: 4000
  4. -- background id: 0
  5. -- name: Division
  6. ----- HyperTalk script -----
  7. function NumberOfTeams
  8. if "National" is in field "Division" then
  9.   put 6 into X
  10. else
  11.   put 7 into X
  12. end if
  13. return X
  14. end NumberOfTeams
  15.  
  16. function PutWinsAndLosses Wins, Losses, WhichLine
  17. if Losses = 0 then
  18.   put 1.000 into Percent
  19. else if Wins = 0 then
  20.   put .000 into Percent
  21. else put "." & round((Wins/(Wins+Losses))*1000) into Percent
  22. put Wins into line WhichLine of field "Wins"
  23. put Losses into line WhichLine of field "Losses"
  24. put 162-Wins-Losses into line WhichLine of field "Games Left"
  25. put Percent into line WhichLine of field "Percent"
  26. get 0.5+(Percent-.5)*((Wins+Losses)/162)
  27. put true into Shifted
  28. repeat while Shifted
  29.   if WhichLine>1 and Percent>line (WhichLine-1) of field "Percent" then
  30.     get SwapLines(WhichLine,WhichLine-1)
  31.     subtract 1 from WhichLine
  32.   else if WhichLine<NumberOfTeams() and Percent<line (WhichLine+1) of field "Percent" then
  33.     get SwapLines(WhichLine,WhichLine+1)
  34.     add 1 to WhichLine
  35.   else
  36.     put False into Shifted
  37.   end if
  38. end repeat
  39. return WhichLine
  40. end PutWinsAndLosses
  41.  
  42. function SwapLines FirstLine, SecondLine
  43. put "Teams,Wins,Losses,Percent,Games Behind" into AllFields
  44. put ",Games Behind - Half,Games Left,Magic Number" after AllFields
  45. repeat with x = 1 to the number of items in AllFields
  46.   put item x of AllFields into WhichField
  47.   put line FirstLine of field WhichField into FirstStuff
  48.   put line SecondLine of field WhichField into SecondStuff
  49.   put FirstStuff into line SecondLine of field WhichField
  50.   put SecondStuff into line FirstLine of field WhichField
  51. end repeat
  52. end SwapLines
  53.  
  54. function IncrementWins WhichLine
  55. put line WhichLine of field "Wins" into Wins
  56. put line WhichLine of field "Losses" into Losses
  57. add 1 to Wins
  58. put PutWinsAndLosses(Wins,Losses,WhichLine) into WhichLine
  59. if line WhichLine of field "Games Behind" contains "-" then
  60.   repeat with x = 1 to NumberOfTeams()
  61.     if x is not WhichLine
  62.     then get IncrementGamesBehind(x)
  63.   end repeat
  64. else get DecrementGamesBehind(WhichLine)
  65. if WhichLine is 1
  66. then repeat with x = 1 to NumberOfTeams()
  67. if x is not WhichLine
  68. then subtract 1 from line x of field "Magic Number"
  69. end repeat
  70. end IncrementWins
  71.  
  72. function IncrementLosses WhichLine
  73. put line WhichLine of field "Wins" into Wins
  74. put line WhichLine of field "Losses" into Losses
  75. add 1 to Losses
  76. put PutWinsAndLosses(Wins,Losses,WhichLine) into WhichLine
  77. put false into NewLeader
  78. if line WhichLine of field "Games Behind" contains "-" then
  79.   repeat with x = 1 to NumberOfTeams()
  80.     if x is not WhichLine then
  81.       if DecrementGamesBehind(x) < 0 then put true into NewLeader
  82.     end if
  83.   end repeat
  84.   if NewLeader then
  85.     choose browse tool
  86.     click at location of field "Games Behind"
  87.   end if
  88. else get IncrementGamesBehind(WhichLine)
  89. if WhichLine is 1 then
  90.   get empty
  91. else subtract 1 from line WhichLine of field "Magic Number"
  92. end IncrementLosses
  93.  
  94. function GetGamesBehind WhichLine
  95. put line WhichLine of field "Games Behind" into GamesBehind
  96. if GamesBehind contains "-" then
  97.   put 0.0 into GamesBehind
  98. end if
  99. if (line WhichLine of field "Games Behind - Half") is empty then
  100.   add 0.0 to GamesBehind
  101. else add 0.5 to GamesBehind
  102. return GamesBehind
  103. end GetGamesBehind
  104.  
  105. function PutGamesBehind GamesBehind, WhichLine
  106. if GamesBehind = 0 then
  107.   put "--" into FormattedGamesBehind
  108. else if GamesBehind = 0.5 then
  109.   put empty into FormattedGamesBehind
  110. else put round(GamesBehind - .25) into FormattedGamesBehind
  111. if GamesBehind = round(GamesBehind) then
  112.   put empty into FormattedHalfGamesBehind
  113. else put "1/2" into FormattedHalfGamesBehind
  114. put FormattedGamesBehind into line WhichLine of field "Games Behind"
  115. put FormattedHalfGamesBehind into line WhichLine of field "Games Behind - Half"
  116. return GamesBehind
  117. end PutGamesBehind
  118.  
  119. function IncrementGamesBehind WhichLine
  120. get GetGamesBehind(WhichLine)
  121. get PutGamesBehind(it+0.5,WhichLine)
  122. return it+0.5
  123. end IncrementGamesBehind
  124.  
  125. function DecrementGamesBehind WhichLine
  126. get GetGamesBehind(WhichLine)
  127. get PutGamesBehind(it-0.5,WhichLine)
  128. return it-0.5
  129. end DecrementGamesBehind
  130.  
  131.  
  132.  
  133.  
  134. -- part 1 (field)
  135. -- low flags: 01
  136. -- high flags: 4000
  137. -- rect: left=14 top=88 right=201 bottom=92
  138. -- title width / last selected line: 0
  139. -- icon id / first selected line: 0 / 0
  140. -- text alignment: 0
  141. -- font id: 3
  142. -- text size: 12
  143. -- style flags: 256
  144. -- line height: 16
  145. -- part name: Teams
  146. ----- HyperTalk script -----
  147. on mouseUp
  148.   put LineOfMouseClick("Teams") into WhichLine
  149.   set the cursor to 4
  150.   get line WhichLine of field "Teams"
  151.   go to card it
  152. end mouseUp
  153.  
  154.  
  155.  
  156. -- part 2 (field)
  157. -- low flags: 01
  158. -- high flags: 4000
  159. -- rect: left=105 top=88 right=201 bottom=140
  160. -- title width / last selected line: 0
  161. -- icon id / first selected line: 0 / 0
  162. -- text alignment: 65535
  163. -- font id: 3
  164. -- text size: 12
  165. -- style flags: 256
  166. -- line height: 16
  167. -- part name: Wins
  168. ----- HyperTalk script -----
  169. on mouseUp
  170.   get (item 2 of rect of field "Teams")
  171.   put (the mouseV - it) into it
  172.   put 1 + (it div (textHeight of field "Teams")) into WhichLine
  173.   set the cursor to 4
  174.   get IncrementWins(WhichLine)
  175. end mouseUp
  176.  
  177.  
  178.  
  179. -- part 3 (field)
  180. -- low flags: 01
  181. -- high flags: 4000
  182. -- rect: left=147 top=88 right=201 bottom=182
  183. -- title width / last selected line: 0
  184. -- icon id / first selected line: 0 / 0
  185. -- text alignment: 65535
  186. -- font id: 3
  187. -- text size: 12
  188. -- style flags: 256
  189. -- line height: 16
  190. -- part name: Losses
  191. ----- HyperTalk script -----
  192. on mouseUp
  193.   get (item 2 of rect of field "Teams")
  194.   put (the mouseV - it) into it
  195.   put 1 + (it div (textHeight of field "Teams")) into WhichLine
  196.   set the cursor to 4
  197.   get IncrementLosses(WhichLine)
  198. end mouseUp
  199.  
  200.  
  201.  
  202. -- part 4 (field)
  203. -- low flags: 01
  204. -- high flags: 4000
  205. -- rect: left=273 top=88 right=201 bottom=300
  206. -- title width / last selected line: 0
  207. -- icon id / first selected line: 0 / 0
  208. -- text alignment: 65535
  209. -- font id: 3
  210. -- text size: 12
  211. -- style flags: 256
  212. -- line height: 16
  213. -- part name: Games Behind
  214. ----- HyperTalk script -----
  215. on mouseUp
  216.   set the cursor to 4
  217.   repeat with WhichLine = 1 to NumberOfTeams()
  218.     put line WhichLine of field "Wins" into Wins
  219.     put line WhichLine of field "Losses" into Losses
  220.     put Wins-Losses into item WhichLine of AllDifferences
  221.   end repeat
  222.   put max(AllDifferences) into MaxWinLossDifference
  223.   repeat with WhichLine = 1 to NumberOfTeams()
  224.     put item WhichLine of AllDifferences into WinLossDifference
  225.     put MaxWinLossDifference - WinLossDifference into WinLossBehind
  226.     put WinLossBehind/2 into GamesBehind
  227.     get PutGamesBehind(GamesBehind,WhichLine)
  228.   end repeat
  229. end mouseUp
  230.  
  231.  
  232.  
  233. -- part 5 (field)
  234. -- low flags: 01
  235. -- high flags: 4000
  236. -- rect: left=417 top=88 right=201 bottom=457
  237. -- title width / last selected line: 0
  238. -- icon id / first selected line: 0 / 0
  239. -- text alignment: 65535
  240. -- font id: 3
  241. -- text size: 12
  242. -- style flags: 256
  243. -- line height: 16
  244. -- part name: Magic Number
  245. ----- HyperTalk script -----
  246. on mouseUp
  247.   set the cursor to 4
  248.   repeat with WhichLine = 1 to NumberOfTeams()
  249.     put line WhichLine of field "Games Left" into GamesLeft
  250.     put GamesLeft into item WhichLine of AllGamesLeft
  251.     put line WhichLine of field "Wins" into Wins
  252.     put line WhichLine of field "Losses" into Losses
  253.     put Wins-Losses into item WhichLine of AllDifferences
  254.     if char 1 of line WhichLine of field "Games Behind" is "-" then
  255.       put item WhichLine of AllDifferences into ThisDifference
  256.       put item WhichLine of AllGamesLeft into ThisGamesLeft
  257.     end if
  258.   end repeat
  259.   repeat with WhichLine = 1 to NumberOfTeams()
  260.     put item WhichLine of AllDifferences into WinLossDifference
  261.     put item WhichLine of AllGamesLeft into GamesLeft
  262.     get ThisGamesLeft+GamesLeft+WinLossDifference-ThisDifference
  263.     put (it/2)+1 into MagicNumber
  264.     if char 1 of line WhichLine of field "Games Behind" is "-"
  265.     then put "--" into MagicNumber
  266.     put MagicNumber into line WhichLine of field "Magic Number"
  267.   end repeat
  268. end mouseUp
  269.  
  270.  
  271.  
  272. -- part 6 (field)
  273. -- low flags: 01
  274. -- high flags: 4000
  275. -- rect: left=200 top=88 right=201 bottom=250
  276. -- title width / last selected line: 0
  277. -- icon id / first selected line: 0 / 0
  278. -- text alignment: 65535
  279. -- font id: 3
  280. -- text size: 12
  281. -- style flags: 256
  282. -- line height: 16
  283. -- part name: Percent
  284. ----- HyperTalk script -----
  285. on mouseUp
  286.   set the cursor to 4
  287.   repeat with FirstLine = 1 to 6
  288.     put line FirstLine of field "Percent" into FirstPercent
  289.     repeat with SecondLine = FirstLine+1 to 7
  290.       put line SecondLine of field "Percent" into SecondPercent
  291.       if FirstPercent < SecondPercent then
  292.         get SwapLines(FirstLine,SecondLine)
  293.         put SecondPercent into FirstPercent
  294.       end if
  295.     end repeat
  296.   end repeat
  297. end mouseUp
  298.  
  299.  
  300.  
  301. -- part 8 (field)
  302. -- low flags: 01
  303. -- high flags: 4000
  304. -- rect: left=345 top=88 right=201 bottom=384
  305. -- title width / last selected line: 0
  306. -- icon id / first selected line: 0 / 0
  307. -- text alignment: 65535
  308. -- font id: 3
  309. -- text size: 12
  310. -- style flags: 256
  311. -- line height: 16
  312. -- part name: Games Left
  313.  
  314.  
  315. -- part 9 (field)
  316. -- low flags: 01
  317. -- high flags: 0000
  318. -- rect: left=305 top=307 right=324 bottom=464
  319. -- title width / last selected line: 0
  320. -- icon id / first selected line: 0 / 0
  321. -- text alignment: 0
  322. -- font id: 3
  323. -- text size: 12
  324. -- style flags: 256
  325. -- line height: 16
  326. -- part name: Date
  327.  
  328.  
  329. -- part 10 (field)
  330. -- low flags: 01
  331. -- high flags: 4000
  332. -- rect: left=299 top=88 right=201 bottom=330
  333. -- title width / last selected line: 0
  334. -- icon id / first selected line: 0 / 0
  335. -- text alignment: 0
  336. -- font id: 3
  337. -- text size: 9
  338. -- style flags: 256
  339. -- line height: 16
  340. -- part name: Games Behind - Half
  341.  
  342.  
  343. -- part 23 (field)
  344. -- low flags: 01
  345. -- high flags: 0000
  346. -- rect: left=12 top=32 right=58 bottom=271
  347. -- title width / last selected line: 0
  348. -- icon id / first selected line: 0 / 0
  349. -- text alignment: 0
  350. -- font id: 3
  351. -- text size: 18
  352. -- style flags: 768
  353. -- line height: 24
  354. -- part name: Division
  355.  
  356.  
  357. -- part 26 (button)
  358. -- low flags: 00
  359. -- high flags: 8003
  360. -- rect: left=12 top=278 right=297 bottom=149
  361. -- title width / last selected line: 0
  362. -- icon id / first selected line: 0 / 0
  363. -- text alignment: 1
  364. -- font id: 0
  365. -- text size: 12
  366. -- style flags: 0
  367. -- line height: 16
  368. -- part name: Change Team Cards
  369. ----- HyperTalk script -----
  370. on mouseUp
  371.   set the cursor to 4
  372.   repeat with WhichLine = 1 to NumberOfTeams()
  373.     put line WhichLine of field "Teams" into WhichTeam
  374.     put "Teams,Wins,Losses,Percent,Games Behind,Games Behind - Half" into FieldsToCopy
  375.     put ",Games Left" after FieldsToCopy
  376.     put the number of this card into WhichDivisionCard
  377.     push this card
  378.     go to card WhichTeam
  379.     put field "Date" of card WhichDivisionCard into field "Date"
  380.     if field "Date" is not field "Clinch Date" then
  381.       put empty into field "Clinch Date"
  382.     end if
  383.     repeat with x = 1 to the number of items in FieldsToCopy
  384.       put item x of FieldsToCopy into WhichField
  385.       get field WhichField of card WhichDivisionCard
  386.       put it into field WhichField
  387.       get line WhichLine of field WhichField
  388.       put empty into line WhichLine of field WhichField
  389.       put empty into field (WhichField & " Bold")
  390.       put it into line WhichLine of field (WhichField & " Bold")
  391.     end repeat
  392.     click at location of field "Magic Number"
  393.     pop card
  394.   end repeat
  395.   choose browse tool
  396. end mouseUp
  397.  
  398.  
  399.  
  400. -- part 28 (field)
  401. -- low flags: 01
  402. -- high flags: 0000
  403. -- rect: left=91 top=88 right=201 bottom=106
  404. -- title width / last selected line: 0
  405. -- icon id / first selected line: 0 / 0
  406. -- text alignment: 0
  407. -- font id: 3
  408. -- text size: 12
  409. -- style flags: 256
  410. -- line height: 16
  411. -- part name: Teams
  412. ----- HyperTalk script -----
  413. on mouseUp
  414.   put LineOfMouseClick("Teams") into WhichLine
  415.   set the cursor to 4
  416.   put line WhichLine of field "Teams" into WhichTeam
  417.   put line WhichLine of field "Wins" into Wins
  418.   put line WhichLine of field "Losses" into Losses
  419.   ask WhichTeam && "Won-Loss Record" with Wins & "," & Losses
  420.   if it is not empty then
  421.     put item 1 of it into Wins
  422.     put item 2 of it into Losses
  423.     put PutWinsAndLosses(Wins,Losses,WhichLine) into WhichLine
  424.     choose browse tool
  425.     click at location of field "Games Behind"
  426.     click at location of field "Magic Number"
  427.   end if
  428. end mouseUp
  429.  
  430.  
  431.  
  432. -- part 29 (button)
  433. -- low flags: 00
  434. -- high flags: 8003
  435. -- rect: left=11 top=311 right=328 bottom=58
  436. -- title width / last selected line: 0
  437. -- icon id / first selected line: 0 / 0
  438. -- text alignment: 1
  439. -- font id: 21
  440. -- text size: 10
  441. -- style flags: 256
  442. -- line height: 13
  443. -- part name: Browse
  444. ----- HyperTalk script -----
  445. on mouseUp
  446.   go to card "Index"
  447. end mouseUp
  448.  
  449.  
  450.  
  451.  
  452. -- part 32 (button)
  453. -- low flags: 00
  454. -- high flags: 8003
  455. -- rect: left=62 top=311 right=328 bottom=109
  456. -- title width / last selected line: 0
  457. -- icon id / first selected line: 0 / 0
  458. -- text alignment: 1
  459. -- font id: 21
  460. -- text size: 10
  461. -- style flags: 256
  462. -- line height: 13
  463. -- part name: Help
  464. ----- HyperTalk script -----
  465. on mouseUp
  466.   go to card "Help"
  467. end mouseUp
  468.  
  469.  
  470.  
  471.  
  472. -- part 33 (button)
  473. -- low flags: 00
  474. -- high flags: 0000
  475. -- rect: left=117 top=307 right=330 bottom=139
  476. -- title width / last selected line: 0
  477. -- icon id / first selected line: 15420 / 15420
  478. -- text alignment: 1
  479. -- font id: 0
  480. -- text size: 12
  481. -- style flags: 0
  482. -- line height: 16
  483. -- part name: GoToPrev
  484. ----- HyperTalk script -----
  485. on mouseUp
  486.   go to previous card
  487. end mouseUp
  488.  
  489.  
  490.  
  491. -- part 34 (button)
  492. -- low flags: 00
  493. -- high flags: 0000
  494. -- rect: left=144 top=306 right=331 bottom=168
  495. -- title width / last selected line: 0
  496. -- icon id / first selected line: 16560 / 16560
  497. -- text alignment: 1
  498. -- font id: 0
  499. -- text size: 12
  500. -- style flags: 0
  501. -- line height: 16
  502. -- part name: GoToPrev
  503. ----- HyperTalk script -----
  504. on mouseUp
  505.   go to next card
  506. end mouseUp
  507.  
  508.